<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\NodeController;
use App\Http\Controllers\FangAttrController;
use App\Http\Controllers\ArticleController;
use App\Http\Controllers\FangController;
use App\Http\Controllers\FangOwnerController;
use App\Http\Controllers\CityController;
use App\Http\Controllers\NoticeController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


    //登录页面
    Route::get('login', [LoginController::class,'index'])->name('admin.login');
    //登录方法
    Route::post('login', [LoginController::class,'login'])->name('admin.login');;
    //退出登录
    Route::get('logout', [LoginController::class,'logout'])->name('admin.logout');

//
////as 别名
Route::middleware(['middleware'=>'check_admin'])->group(function () {
    //首页页面
    Route::get('index', [IndexController::class,'index'])->name('admin.index');
    //后台欢迎页面
    Route::get('welcome', [IndexController::class,'welcome'])->name('admin.welcome');
    //管理员列表
    Route::get('user/index', [UserController::class,'index'])->name('admin.user.index');
    //管理员添加页面
    Route::get('user/add', [UserController::class,'add'])->name('admin.user.add');
    //管理员添加方法
    Route::post('user/add', [UserController::class,'create'])->name('admin.user.add');
    //管理员删除功能
    Route::get('user/del', [UserController::class,'del'])->name('admin.user.del');
    //管理员的单个恢复
    Route::get('user/restore', [UserController::class,'restore'])->name('admin.user.restore');
    //管理员修改页面
    Route::get('user/edit', [UserController::class,'edit'])->name('admin.user.edit');
    //管理员执行修改
    Route::post('user/update', [UserController::class,'update'])->name('admin.user.update');

    //用户分配角色页面和方法路由
    Route::match(['get', 'post'], 'user/role/{user}', [UserController::class,'role'])->name('admin.user.role');


    //分配权限
    Route::get('role/node/{role}', [RoleController::class,'node'])->name('admin.role.node');
    //执行分配权限
    Route::post('role/node/{role}', [RoleController::class,'nodeSave'])->name('admin.role.node');
    //角色展示
    Route::get('role/index', [RoleController::class,'index'])->name('admin.role.index');
    //角色添加页面
    Route::get('role/create', [RoleController::class,'create'])->name('admin.role.create');
    //角色执行添加
    Route::post('role/store', [RoleController::class,'store'])->name('admin.role.store');
    //角色修改页面
    Route::get('role/edit', [RoleController::class,'edit'])->name('admin.role.edit');
    //角色执行修改
    Route::post('role/update', [RoleController::class,'update'])->name('admin.role.update');
    //角色删除
    Route::get('role/destroy', [RoleController::class,'destroy'])->name('admin.role.destroy');


    //节点列表
    Route::get('node/index', [NodeController::class,'index'])->name('admin.node.index');
    //节点添加列表
    Route::get('node/create', [NodeController::class,'create'])->name('admin.node.create');
    //节点执行添加
    Route::post('node/store', [NodeController::class,'store'])->name('admin.node.store');
    //节点修改页面
    Route::get('node/edit', [NodeController::class,'edit'])->name('admin.node.edit');
    //节点执行修改
    Route::post('node/update', [NodeController::class,'update'])->name('admin.node.update');
    //节点删除
    Route::get('node/destroy', [NodeController::class,'destroy'])->name('admin.node.destroy');


    //文章展示
    Route::get('article/index', [ArticleController::class,'index'])->name('admin.article.index');
    //文章导出
    Route::get('article/export', [ArticleController::class,'export'])->name('admin.article.export');
    //文章添加
    Route::get('article/create', [ArticleController::class,'create'])->name('admin.article.create');
    //文章执行添加
    Route::post('article/store', [ArticleController::class,'store'])->name('admin.article.store');
    //文章删除
    Route::get('article/destroy', [ArticleController::class,'destroy'])->name('admin.article.destroy');
    //文章修改页面
    Route::get('article/edit', [ArticleController::class,'edit'])->name('admin.article.edit');
    //文章执行修改
    Route::post('article/update', [ArticleController::class,'update'])->name('admin.article.update');

    //文章图片上传
    Route::post('article/local_upfile', [ArticleController::class,'localUploadFile'])->name('admin.article.local_upfile');


    //房源属性图片上传
    Route::post('fang_attr/oss_upfile', [FangAttrController::class,'ossUploadFile'])->name('admin.fang_attr.oss_upfile');
    //房屋展示
    Route::get('fang_attr/index', [FangAttrController::class,'index'])->name('admin.fang_attr.index');
    //房屋添加
    Route::get('fang_attr/create', [FangAttrController::class,'create'])->name('admin.fang_attr.create');
    //房屋执行添加
    Route::post('fang_attr/store', [FangAttrController::class,'store'])->name('admin.fang_attr.store');
    //房屋修改
    Route::get('fang_attr/edit', [FangAttrController::class,'edit'])->name('admin.fang_attr.edit');
    //房屋执行修改
    Route::post('fang_attr/update', [FangAttrController::class,'update'])->name('admin.fang_attr.update');
    //房屋删除
    Route::get('fang_attr/destroy', [FangAttrController::class,'destroy'])->name('admin.fang_attr.destroy');


    //房东属性图片上传
    Route::post('fang_owner/oss_upfile', [FangOwnerController::class,'localUploadFile'])->name('admin.fang_owner.oss_upfile');
    //删除图片
    Route::delete('fang_owner/delfile', [FangOwnerController::class,'DelFile'])->name('admin.fang_owner.delfile');
    //房东展示
    Route::get('fang_owner/index', [FangOwnerController::class,'index'])->name('admin.fang_owner.index');
    //房东添加
    Route::get('fang_owner/create', [FangOwnerController::class,'create'])->name('admin.fang_owner.create');
    //房东执行添加
    Route::post('fang_owner/store', [FangOwnerController::class,'store'])->name('admin.fang_owner.store');
    //房东修改
    Route::get('fang_owner/edit', [FangOwnerController::class,'edit'])->name('admin.fang_owner.edit');
    //房东执行修改
    Route::post('fang_owner/update', [FangOwnerController::class,'update'])->name('admin.fang_owner.update');
    //房东删除
    Route::get('fang_owner/destroy', [FangOwnerController::class,'destroy'])->name('admin.fang_owner.destroy');


    //房源图片上传
    Route::post('fang/UploadFile', [FangController::class,'UploadFile'])->name('admin.fang.UploadFile');
    Route::delete('fang/delfile', [FangController::class,'DelFile'])->name('admin.fang.delfile');
    //房源展示
    Route::get('fang/index', [FangController::class,'index'])->name('admin.fang.index');
    //房源添加
    Route::get('fang/create', [FangController::class,'create'])->name('admin.fang.create');
    //房源执行添加
    Route::post('fang/store', [FangController::class,'store'])->name('admin.fang.store');
    //城市
    Route::get('city', [CityController::class,'getCity'])->name('admin.city');
    //elk
    Route::get('fang/esindex', [FangController::class,'createFangEs'])->name('admin.fang.esindex');
    //即点即改
    Route::get('fang/change_status', [FangController::class,'changFangStatus'])->name('admin.fang.change_status');


    Route::get('notice/index',[NoticeController::class,'index'])->name('admin.notice.index');
    Route::get('notice/create',[NoticeController::class,'create'])->name('admin.notice.create');
    Route::post('notice/store',[NoticeController::class,'store'])->name('admin.notice.store');

});

